package com.zlp.netty.nio;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author: zhulaiping
 * @time: 2022/8/8 15:53
 */
public class BioDemo2_Chat {



    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(9999);
        List<BufferedReader> list = new ArrayList<>();
        while (true){
            Socket socket = serverSocket.accept();
            BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));

            //PrintStream ps = new PrintStream(socket.getOutputStream());
            list.add(br);
            for (BufferedReader bufferedReader:list){
                System.out.println(bufferedReader.readLine());
            }
        }
    }


}
